package com.ruoyi.wechat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.CLeaseorder;
import com.ruoyi.wechat.service.ICLeaseorderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 租赁订单Controller
 * 
 * @author ruoyi
 * @date 2024-12-25
 */
@RestController
@RequestMapping("/camp/leaseorder")
public class CLeaseorderController extends BaseController
{
    @Autowired
    private ICLeaseorderService cLeaseorderService;

    /**
     * 查询租赁订单列表
     */
    @PreAuthorize("@ss.hasPermi('camp:leaseorder:list')")
    @GetMapping("/list")
    public TableDataInfo list(CLeaseorder cLeaseorder)
    {
        startPage();
        List<CLeaseorder> list = cLeaseorderService.selectCLeaseorderList(cLeaseorder);
        return getDataTable(list);
    }

    /**
     * 导出租赁订单列表
     */
    @PreAuthorize("@ss.hasPermi('camp:leaseorder:export')")
    @Log(title = "租赁订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CLeaseorder cLeaseorder)
    {
        List<CLeaseorder> list = cLeaseorderService.selectCLeaseorderList(cLeaseorder);
        ExcelUtil<CLeaseorder> util = new ExcelUtil<CLeaseorder>(CLeaseorder.class);
        util.exportExcel(response, list, "租赁订单数据");
    }

    /**
     * 获取租赁订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('camp:leaseorder:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") String orderId)
    {
        return success(cLeaseorderService.selectCLeaseorderByOrderId(orderId));
    }

    /**
     * 新增租赁订单
     */
    @PreAuthorize("@ss.hasPermi('camp:leaseorder:add')")
    @Log(title = "租赁订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CLeaseorder cLeaseorder)
    {
        return toAjax(cLeaseorderService.insertCLeaseorder(cLeaseorder));
    }

    /**
     * 修改租赁订单
     */
    @PreAuthorize("@ss.hasPermi('camp:leaseorder:edit')")
    @Log(title = "租赁订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CLeaseorder cLeaseorder)
    {
        return toAjax(cLeaseorderService.updateCLeaseorder(cLeaseorder));
    }

    /**
     * 删除租赁订单
     */
    @PreAuthorize("@ss.hasPermi('camp:leaseorder:remove')")
    @Log(title = "租赁订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable String[] orderIds)
    {
        return toAjax(cLeaseorderService.deleteCLeaseorderByOrderIds(orderIds));
    }
}
